package com.future.direction.ui.activity;

import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;

import com.future.direction.R;
import com.future.direction.common.Constant;
import com.future.direction.common.util.StringUtil;
import com.future.direction.common.util.UIUtil;
import com.future.direction.di.component.AppComponent;
import com.future.direction.interfaces.OnItemClickListener;
import com.future.direction.ui.adapter.DiamondsRecordAdapter;
import com.future.direction.ui.widget.MyTitleBar;

import butterknife.BindView;

/**
 * Created by zhp on 2019-11-08
 */
public class DiamondsRecordActivity extends BaseActivity {

    @BindView(R.id.titleBar)
    MyTitleBar titleBar;
    @BindView(R.id.recycle_diamonds)
    RecyclerView recycleDiamonds;
    private DiamondsRecordAdapter diamondsRecordAdapter;

    @Override
    public int setLayout() {
        return R.layout.activity_diamonds_record;
    }

    @Override
    public void getExtras() {
        String title = getIntent().getStringExtra(Constant.data);
        if (StringUtil.isNotNullString(title)) {
            titleBar.setTitle(title);
        }
    }

    @Override
    public boolean init() {
        initRecycle();
        return false;
    }

    @Override
    public void setListener() {
        backListener(titleBar);
        diamondsRecordAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                Intent intent = new Intent(DiamondsRecordActivity.this, DiamondsDetailsActivity.class);
                startActivity(intent);
            }
        });
    }

    @Override
    public void setupAcitivtyComponent(AppComponent appComponent) {

    }

    private void initRecycle() {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(UIUtil.getContext(), LinearLayout.VERTICAL, false);
        recycleDiamonds.setLayoutManager(linearLayoutManager);
        diamondsRecordAdapter = new DiamondsRecordAdapter();
        recycleDiamonds.setAdapter(diamondsRecordAdapter);
    }
}
